package com.ruoyi.web.controller.kaoyan.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.kaoyan.domain.EducationMessage;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author carpediem
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class MessageVo {

    private Long id;

    private String content;

    private String isRead;

    private Long sender;
    private String senderName;

    private Long receiver;
    private String receiverName;

    private String requestId;

    private String isLast;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    public MessageVo(EducationMessage message, Map<Long, String> map, Map<Long, String> map2){
        this.id = message.getId();
        this.createTime = message.getCreateTime();
        this.receiver = message.getReceiver();
        this.sender = message.getSender();
        this.senderName = map.get(message.getSender());
        this.receiverName = map2.get(message.getReceiver());
        this.content = message.getContent();
    }
}
